package com.lft.sort.algorithms;

/**
 * Function: 		A {@code SortAlgorithmsTest} object With Some FUNCTION.<br/>
 * Reason:   		ADD REASON.<br/>
 * Date:            2021-02-26 14:09<br/>
 * <p>
 * Class Name:      SortAlgorithmsTest<br/>
 * Package Name:    com.lft.sort.algorithms<br/>
 * @author Laifengting / E-mail:laifengting@foxmail.com
 * @version 1.0.0
 * @since JDK 8
 */
public class SortAlgorithmsTest {
	public static void main(String[] args) {
		// double[] a = new double[80000];
		int[] a = new int[80000];
		for (int i = 0; i < a.length; i++) {
			a[i] = (int) (Math.random() * 80000);
		}
		
		// double[] a = {101, 34, 119, 1, -12.5, -1, -12};
		// System.out.println("排序前数组为：" + Arrays.toString(a));
		
		System.gc();
		long start = System.currentTimeMillis();
		long startFreeMemory = Runtime.getRuntime().freeMemory();
		
		// Date date1 = new Date();
		// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.sss");
		// String t1 = simpleDateFormat.format(date1);
		
		// double[] as = SortUtils.bubbleSort(a); // 12695ms 5263kb
		// double[] as = SortUtils.selectionSort(a); // 6141ms 5263kb
		// double[] as = SortUtils.insertSort(a); // 776ms 0kb // 加了判断 1321ms 5263kb
		// double[] as = SortUtils.sheelSort(a); // 交换式： 12136ms 5263kb // 移位式：15ms 0kb
		// double[] as = SortUtils.quickSort(a, 0, a.length - 1); // 14ms 0kb
		// double[] as = SortUtils.mergeSort(a, 0, a.length - 1, new double[a.length]); // 11ms 0kb
		int[] as = SortUtils.radixSort(a); // 8ms 3256kb
		// double[] as = SortUtils.bubbleSort(a);
		
		// Date date2 = new Date();
		// String t2 = simpleDateFormat.format(date2);
		
		long end = System.currentTimeMillis();
		long endFreeMemory = Runtime.getRuntime().freeMemory();
		
		// System.out.println("排序后数组为："+Arrays.toString(as));
		System.out.println("执行用时：" + (end - start) + " 毫秒");
		// System.out.println("执行用时：" + t1 + " - " + t2);
		System.out.println("执行占用内存：" + (startFreeMemory - endFreeMemory) / 1024 + " KB");
		
	}
}
